package Servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Logic.OperateLogic;
import Logic.TeacherLogic;
import Model.MemberBean;
import Model.OperateBean;
import Model.TeacherBean;

@SuppressWarnings("serial")
public class TeacherServlet extends HttpServlet{
	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response)
				throws ServletException, IOException {
		
		 response.setCharacterEncoding("utf-8");
		 response.setContentType("text/html;charset=utf-8");
		 PrintWriter out = response.getWriter();
		 String opType = request.getParameter("opType"); 
	}
		 
	    // 接收客户端浏览器的POST请求，由Service方法跳转
	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response)
	    		throws ServletException, IOException {		
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		String opType = request.getParameter("opType");
		
		if (opType.equals("addTeacher")){        	        	
			 String TeacherID = request.getParameter("TeacherID");
			 String TeacherName = request.getParameter("TeacherName");
			 
			 TeacherBean teacherbean = new TeacherBean();			
			 teacherbean.setTeacherID(Integer.parseInt(TeacherID));
			 teacherbean.setTeacherName(TeacherName);
			 
			 TeacherLogic teacherlogic = new TeacherLogic();
			 teacherlogic.addTeacher(teacherbean);

			 out.print(1);
		 }
		
	}
	        
}
